import static org.junit.Assert.*;

import org.junit.Test;


public class TestSavingsAccount {

	@Test
	public void test() {
		Person p1 = new Person("testAccount1", "street1", "zip1", "town1", "country1");
		Person p2 = new Person("testAccount2", "street2", "zip2", "town2", "country2");
		Person p3 = new Person("testAccount3", "street3", "zip3", "town3", "country3");
		SavingsAccount testAccount1 = new SavingsAccount(p1);
		SavingsAccount testAccount2 = new SavingsAccount(p2);
		SavingsAccount testAccount3 = new SavingsAccount(p3);
		

		assertFalse(testAccount1.equals(testAccount2));
		assertFalse(testAccount1.equals(testAccount3));
		assertTrue(testAccount1.equals(testAccount1));
		assertTrue(testAccount2.equals(testAccount2));
		assertTrue(testAccount3.equals(testAccount3));

		assertEquals(testAccount1.getBalance(), 0.0, 0.0000001);
		assertEquals(testAccount2.getBalance(), 0.0, 0.0000001);
		
//		assertTrue(testAccount1.getAccountNumber() == 0);
//		assertTrue(testAccount2.getAccountNumber() == 1);
//		assertTrue(testAccount3.getAccountNumber() == 2);

		assertFalse(testAccount1.withdrawal(10.0));
		assertEquals(testAccount1.getBalance(), 0.0, 0.0000001);
//		testAccount1.decreaseBalance(10.0);
//		assertTrue(testAccount1.getBalance() == -10.0);
//		assertFalse(testAccount1.applyForCreditCard("", "", "", "", "", testAccount1.getAccountNumber()));
//		testAccount1.setBalance(0.0);
		assertEquals(testAccount1.getBalance(), 0.0, 0.0000001);
		assertFalse(testAccount2.withdrawal(10.0));
		assertEquals(testAccount2.getBalance(), 0.0, 0.0000001);
//		assertTrue(testAccount3.withdrawal(190.0));
//		assertFalse(testAccount3.withdrawal(20.0));
//		assertTrue(testAccount2.getBalance() == -190.0);

		testAccount1.verseMoney(20.0);
		assertEquals("increase balance failed", testAccount1.getBalance(), 20.0, 0.0000001);
		testAccount1.verseMoney(30.0);
		assertEquals("verse money failed", testAccount1.getBalance(), 50.0, 0.0000001);
		assertTrue(testAccount1.withdrawal(35.0));
		assertEquals("Withdrawal failed", testAccount1.getBalance(), 15.0, 0.0000001);
//		testAccount1.determineCosts();
//		testAccount3.determineCosts();
//		assertTrue("period costs were not calculated", testAccount1.getBalance() == 49.0);
//		assertFalse("period cost negative penalty wasnt calculated", testAccount3.getBalance() == -191.0);
//		

		CheckingAccount testBlankAccount = new CheckingAccount(32);
		assertEquals(testBlankAccount.getAccountNumber(), 32);

		assertEquals(testBlankAccount.getDebitAmount(),  0.0, 0.0000001);
		assertEquals(testBlankAccount.getBalance(), 0.0, 0.0000001);
		testBlankAccount.increaseBalance(10000.0);
		assertEquals(testBlankAccount.getBalance(), 10000.0, 0.0000001);
		CreditCard cc = testBlankAccount.applyForCreditCard(p1, testBlankAccount.getAccountNumber());
		assertNotEquals("SavingsAccount CC application didnt work", cc, null);
		testAccount1.print();
//		CheckingAccount numberCheck = new CheckingAccount("testAccount4", "street4", "zip4", "town4", "country4");
//		assertTrue(numberCheck.getAccountNumber() == 3);
	}
}
